package two;

// 1. 修改导入语句，使用 JUnit 4 的包
import org.junit.Test;
import static org.junit.Assert.*;

public class ExerciseUnitTestV2 {

    // 2. 将 @Test 注解改为 JUnit 4 的版本
    @Test
    public void testAddExercises() {
        ExerciseV2 addExercises = new ExerciseV2(50, "add");
        assertEquals(50, addExercises.getExercises().size());
        for (AbstractExpression expr : addExercises.getExercises()) {
            assertTrue(expr instanceof AddExpression);
            assertTrue(expr.toString().contains("+"));
        }
    }

    @Test
    public void testSubtractExercises() {
        ExerciseV2 subExercises = new ExerciseV2(50, "subtract");
        assertEquals(50, subExercises.getExercises().size());
        for (AbstractExpression expr : subExercises.getExercises()) {
            assertTrue(expr instanceof SubtractExpression);
            assertTrue(expr.toString().contains("-"));
        }
    }

    @Test
    public void testMixExercises() {
        ExerciseV2 mixExercises = new ExerciseV2(50, "mix");
        assertEquals(50, mixExercises.getExercises().size());
        boolean hasAdd = false;
        boolean hasSub = false;
        for (AbstractExpression expr : mixExercises.getExercises()) {
            if (expr instanceof AddExpression) hasAdd = true;
            if (expr instanceof SubtractExpression) hasSub = true;
        }
        assertTrue(hasAdd && hasSub); // 同时包含加减
    }
}